<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="!crud.props.searchToggle">
        <el-form size="small" label-width="70px">
          <el-row :gutter="10">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="客户名称">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="销售部门">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="销售人员">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="客户分类">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="客户区域">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <rrOperation :crud="crud"/>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="id">
            <el-input v-model="form.id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="库存结算记录id" prop="orderId">
            <el-input v-model="form.orderId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="库存记录id" prop="existsId">
            <el-input v-model="form.existsId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="平均含税成本价">
            <el-input v-model="form.averageCostTaxPrice" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="平均未税成本价">
            <el-input v-model="form.averageCostNoTaxPrice" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="期初数量">
            <el-input v-model="form.beginGoodsCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="期初含税金额">
            <el-input v-model="form.beginTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="期初未税金额">
            <el-input v-model="form.beginNoTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="入库数量">
            <el-input v-model="form.inGoodsCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="入库金额">
            <el-input v-model="form.inTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="入库未税金额">
            <el-input v-model="form.inNoTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="出库数量">
            <el-input v-model="form.outGoodsCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="出库金额">
            <el-input v-model="form.outTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="出库未税金额">
            <el-input v-model="form.outNoTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="期末数量">
            <el-input v-model="form.endGoodsCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="期末含税金额">
            <el-input v-model="form.endTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="期末未税金额">
            <el-input v-model="form.endNoTaxAmount" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" stripe border v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column type="index" width="55" label="序号"/>
        <el-table-column v-if="columns.visible('id')" prop="id" label="id" />
        <el-table-column v-if="columns.visible('orderId')" prop="orderId" label="库存结算记录id" />
        <el-table-column v-if="columns.visible('existsId')" prop="existsId" label="库存记录id" />
        <el-table-column v-if="columns.visible('averageCostTaxPrice')" prop="averageCostTaxPrice" label="平均含税成本价" />
        <el-table-column v-if="columns.visible('averageCostNoTaxPrice')" prop="averageCostNoTaxPrice" label="平均未税成本价" />
        <el-table-column v-if="columns.visible('beginGoodsCount')" prop="beginGoodsCount" label="期初数量" />
        <el-table-column v-if="columns.visible('beginTaxAmount')" prop="beginTaxAmount" label="期初含税金额" />
        <el-table-column v-if="columns.visible('beginNoTaxAmount')" prop="beginNoTaxAmount" label="期初未税金额" />
        <el-table-column v-if="columns.visible('inGoodsCount')" prop="inGoodsCount" label="入库数量" />
        <el-table-column v-if="columns.visible('inTaxAmount')" prop="inTaxAmount" label="入库金额" />
        <el-table-column v-if="columns.visible('inNoTaxAmount')" prop="inNoTaxAmount" label="入库未税金额" />
        <el-table-column v-if="columns.visible('outGoodsCount')" prop="outGoodsCount" label="出库数量" />
        <el-table-column v-if="columns.visible('outTaxAmount')" prop="outTaxAmount" label="出库金额" />
        <el-table-column v-if="columns.visible('outNoTaxAmount')" prop="outNoTaxAmount" label="出库未税金额" />
        <el-table-column v-if="columns.visible('endGoodsCount')" prop="endGoodsCount" label="期末数量" />
        <el-table-column v-if="columns.visible('endTaxAmount')" prop="endTaxAmount" label="期末含税金额" />
        <el-table-column v-if="columns.visible('endNoTaxAmount')" prop="endNoTaxAmount" label="期末未税金额" />
        <el-table-column v-permission="['admin','wareStockSettlementDetail:edit','wareStockSettlementDetail:del']" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudWareStockSettlementDetail from '@/api/erp/wareStockSettlementDetail'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

// crud交由presenter持有
const defaultCrud = CRUD({ title: '库存结算明细', url: 'api/wareStockSettlementDetail', sort: 'id,desc', crudMethod: { ...crudWareStockSettlementDetail }})
const defaultForm = { id: null, orderId: null, existsId: null, averageCostTaxPrice: null, averageCostNoTaxPrice: null, beginGoodsCount: null, beginTaxAmount: null, beginNoTaxAmount: null, inGoodsCount: null, inTaxAmount: null, inNoTaxAmount: null, outGoodsCount: null, outTaxAmount: null, outNoTaxAmount: null, endGoodsCount: null, endTaxAmount: null, endNoTaxAmount: null }
export default {
  name: 'WareStockSettlementDetail',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  data() {
    return {
      
      permission: {
        add: ['admin', 'wareStockSettlementDetail:add'],
        edit: ['admin', 'wareStockSettlementDetail:edit'],
        del: ['admin', 'wareStockSettlementDetail:del'],
        import: ['admin', 'wareStockSettlementDetail:import'],
        export: ['admin', 'wareStockSettlementDetail:export'],
        copy: ['admin', 'wareStockSettlementDetail:copy'],
        upload: ['admin', 'wareStockSettlementDetail:upload'],
        download: ['admin', 'wareStockSettlementDetail:download'],
      },
      rules: {
        orderId: [
          { required: true, message: '库存结算记录id不能为空', trigger: 'blur' }
        ],
        existsId: [
          { required: true, message: '库存记录id不能为空', trigger: 'blur' }
        ]
      }    }
  },
  watch: {
  },
  methods: {
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }, // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {
    },

  }
}
</script>

<style scoped>
  .table-img {
    display: inline-block;
    text-align: center;
    background: #ccc;
    color: #fff;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    vertical-align: middle;
    width: 32px;
    height: 32px;
    line-height: 32px;
  }
</style>
